<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Rspamd Web Interface</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta name="description" content="">
	<meta name="author" content="">

	<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png?v=3">
	<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png?v=3">
	<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png?v=3">
	<link rel="mask-icon" href="safari-pinned-tab.svg?v=3" color="#5bbad5">
	<link rel="shortcut icon" href="favicon.ico?v=3">
	<meta name="msapplication-TileColor" content="#2b5797">

	<link href="./css/bootstrap.min.css" rel="stylesheet">
	<link rel="stylesheet" type="text/css" href="./css/font-glyphicons.css">
	<link rel="stylesheet" type="text/css" href="./css/footable.standalone.min.css"/>
	<link rel="stylesheet" type="text/css" href="./css/FooTable.Glyphicons.css"/>
	<link rel="stylesheet" type="text/css" href="./css/svg-with-js.min.css">
	<link rel="stylesheet" type="text/css" href="./css/d3evolution.css">
	<link rel="stylesheet" type="text/css" href="./css/nprogress.css"/>
	<link rel="stylesheet" type="text/css" href="./css/prism.css"/>
	<link href="./css/rspamd.css" rel="stylesheet">
</head>

<body>

<nav class="navbar navbar-light bg-light navbar-expand-md d-none" id="navBar">
	<form class="form-inline mr-auto">
	<div class="navbar-header navbar-brand p-0">
		<img src="./img/rspamd_logo_navbar.png" alt="Rspamd">
	</div>
		<select id="selSrv" class="form-control"></select>
	</form>
	<ul class="nav navbar-nav nav-pills nav-tabs-sticky" role="tablist">
		<li role="presentation" class="nav-item"><a id="status_nav" aria-controls="status" role="tab" href="#status" data-toggle="tab" class="nav-link">Status</a></li>

		<li role="presentation" class="nav-item"><a id="throughput_nav" aria-controls="throughput" role="tab" href="#throughput" data-toggle="tab" class="nav-link">Throughput</a></li>

		<li role="presentation" class="nav-item"><a id="configuration_nav" aria-controls="configuration" role="tab" href="#configuration" data-toggle="tab" class="nav-link">Configuration</a></li>
		<li role="presentation" class="nav-item"><a id="symbols_nav" aria-controls="symbols" role="tab" href="#symbols" data-toggle="tab" class="nav-link">Symbols</a></li>
		<li role="presentation" class="nav-item"><a id="scan_nav" aria-controls="scan" role="tab" href="#scan" data-toggle="tab" class="nav-link">Scan<span class="ro-hide" style="display: none;">/Learn</span></a></li>
		<li role="presentation" class="nav-item"><a id="selectors_nav" aria-controls="selectors" role="tab" href="#selectors" data-toggle="tab" class="nav-link ro-hide" style="display: none;">Test selectors</a></li>
		<li role="presentation" class="nav-item"><a id="history_nav" aria-controls="history" role="tab" href="#history" data-toggle="tab" class="nav-link">History</a></li>
	</ul>
	<form class="form-inline ml-auto">
		<div class="btn-group">
			<button class="btn btn-outline-secondary" id="refresh" style="display: none;"><i class="fas fa-sync-alt"></i> Refresh</a>
			<button class="btn btn-outline-secondary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" id="autoRefresh" title="Auto-refresh time interval">
				<span id="countdown">--:--</span>
			</button>
			<div class="dropdown-menu">
				<a class="dropdown-item preset" href="#" data-value=null>Disable</a>
				<div class="dropdown-divider preset" role="separator"></div>
				<a class="dropdown-item preset active" href="#" data-value="10000">10 seconds</a>
				<a class="dropdown-item preset" href="#" data-value="30000">30 seconds</a>
				<div class="dropdown-divider preset" role="separator"></div>
				<a class="dropdown-item preset" href="#" data-value="60000">1 minute</a>
				<a class="dropdown-item preset" href="#" data-value="600000">10 minutes</a>
				<a class="dropdown-item preset" href="#" data-value="1800000">30 minutes</a>
				<div class="dropdown-divider preset" role="separator"></div>
				<a class="dropdown-item preset" href="#" data-value="3600000">1 hour</a>

				<a class="dropdown-item dynamic" href="#" data-value=null>Disable</a>
				<div class="dropdown-divider dynamic" role="separator"></div>
				<a class="dropdown-item dynamic active" href="#" id="dynamic-item" data-value="3600000">1 hour</a>
			</div>
		</div>
		<button class="btn btn-outline-secondary ml-2" id="disconnect"><i class="fas fa-power-off"></i> Disconnect</a>
	</form>
</nav>

<div class="notification-area">
	<noscript>
    	<div class="alert alert-error"><strong>Please enable JavaScript</strong></div>
    </noscript>
</div>

<div id="preloader" class="container-fluid">
	<div id="loading" class="position-absolute align-items-center my-3 text-primary blinking d-none">
		<div class="spinner-border align-middle" role="status" aria-hidden="true"></div>
		<strong class="ml-3">Loading...</strong>
	</div>
	<script>document.getElementById("loading").classList.remove("d-none");</script>
	<div class="row position-absolute w-100 h-100 align-items-center text-center">
		<img class="img-fluid mh-100 mx-auto" src="./img/rspamd_logo_navbar.png" alt="Rspamd" />
	</div>
</div>

<div id="mainUI" class="d-none">

	<div class="container-fluid">

		<div class="tab-content">
			<div class="tab-pane active" id="status">
				<div class="row">
					<div id="statWidgets" class="col-lg-12 stat-boxes font-weight-bold text-secondary" style="display: none;">
					</div>
				</div>
				<div class="row">
					<div class="col-lg-6">
						<div class="card bg-light shadow my-3">
							<div class="card-header text-secondary py-2">
								<span class="icon mr-3"><i class="fas fa-server"></i></span>
								<span class="h6 font-weight-bolder my-2">Servers</span>
							</div>
								<div class="card-body p-0 table-responsive">
									<table class="table status-table table-sm table-hover table-bordered text-nowrap mb-0" id="clusterTable">
										<thead class="text-secondary">
											<tr>
												<th></th>
												<th>Server name</th>
												<th>Host</th>
												<th class="w-1">Status</th>
												<th class="w-1">Uptime</th>
												<th class="w-1">Version</th>
												<th>Configuration ID</th>
											</tr>
										</thead>
										<tbody>
										</tbody>
									</table>
								</div>
						</div>
						<div class="card bg-light shadow my-3">
							<div class="card-header text-secondary py-2">
								<span class="icon mr-3"><i class="fas fa-dice"></i></span>
								<span class="h6 font-weight-bolder my-2">Bayesian statistics</span>
							</div>
								<div class="card-body p-0 table-responsive">
									<table class="table status-table table-sm table-bordered text-nowrap mb-0" id="bayesTable">
										<thead class="text-secondary">
											<tr>
												<th>Server name</th>
												<th>Symbol</th>
												<th>Type</th>
												<th>Learns</th>
												<th>Users</th>
											</tr>
										</thead>
										<tbody>
										</tbody>
									</table>
								</div>
						</div>
						<div class="card bg-light shadow my-3">
							<div class="card-header text-secondary py-2">
								<span class="icon mr-3"><i class="fas fa-hashtag"></i></span>
								<span class="h6 font-weight-bolder my-2">Fuzzy hashes</span>
							</div>
								<div class="card-body p-0 table-responsive">
									<table class="table status-table table-sm table-bordered text-nowrap mb-0" id="fuzzyTable">
										<thead class="text-secondary">
											<tr>
												<th>Server name</th>
												<th>Storage</th>
												<th>Hashes</th>
											</tr>
										</thead>
										<tbody>
										</tbody>
									</table>
								</div>
						</div>
					</div>
					<div class="col-lg-6">
						<div class="card bg-light shadow my-3">
							<div class="card-header text-secondary py-2">
								<span class="icon mr-3"><i class="fas fa-chart-pie"></i></span>
								<span class="h6 font-weight-bolder my-2">Statistics</span>
							</div>
							<div class="card-body">
								<div class="row">
									<div class="bg-white mx-auto" id="chart"></div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>

			<div class="tab-pane" id="throughput">
				<div class="card bg-light shadow my-3">
					<div class="card-header text-secondary py-2">
						<span class="icon mr-3"><i class="fas fa-chart-area"></i></span>
						<span class="h6 font-weight-bolder my-2">Throughput</span>
					</div>
					<div class="card-body text-center">
						<div class="d-inline-block bg-white">
							<div class="row">
								<div id="graph" class="mx-auto"></div>
							</div>
							<div id="summary-row" class="row">
								<div class="col-fixed" id="rrd-pie"></div>
								<div class="col-fluid">
									<table id="rrd-table" class="table table-striped table-hover"></table>
									<div id="rrd-table_toggle"></div>
									<div id="rrd-total">Total messages: <span id="rrd-total-value"></span></div>
								</div>
							</div>
						</div>
					</div>
					<div class="card-footer pt-0 text-center">
						<form id="graph_controls" action="#">
							Dataset:
							<select id="selData" class="form-control">
								<option value="day" selected>By day</option>
								<option value="week">By week</option>
								<option value="month">By month</option>
								<option value="year">By year</option>
							</select>
							Y-scale:
							<select id="selYScale" class="form-control">
								<option value="lin" selected>Lin</option>
								<option value="log">Log</option>
							</select>
							Convert to:
							<select id="selConvert" class="form-control">
								<option value="" selected>--</option>
								<option value="percentage">percentage</option>
							</select>
							Chart type:
							<select id="selType" class="form-control">
								<option value="line" selected>Line</option>
								<option value="area">Stacked area</option>
							</select>
							<a title="&ldquo;Curves&rdquo; section of &ldquo;d3-shape&rdquo; library documentation" href="https://github.com/d3/d3-shape#curves" target="_blank">Interpolation mode</a>:
							<select id="selInterpolate" class="form-control">
								<option value="curveLinear" selected>linear</option>
								<option value="curveStep">step</option>
								<option value="curveStepBefore">stepBefore</option>
								<option value="curveStepAfter">stepAfter</option>
								<option value="curveBasis">basis</option>
								<option value="curveBasisOpen">basisOpen</option>
								<option value="curveBundle">bundle</option>
								<option value="curveCardinal">cardinal</option>
								<option value="curveCardinalOpen">cardinalOpen</option>
								<option value="curveMonotoneX">monotoneX</option>
							</select>
						</form>
					</div>
				</div>
			</div>

			<div class="tab-pane" id="configuration">
				<div class="card bg-light shadow my-3">
					<div class="card-header text-secondary py-2">
						<span class="icon mr-3"><i class="fas fa-tasks"></i></span>
						<span class="h6 font-weight-bolder my-2">Actions</span>
					</div>
					<div class="card-body pb-2">
						<form id="actionsForm">
							<fieldset id="actionsFormField" class="ro-disable"></fieldset>
						</form>
					</div>
					<div class="card-footer ro-hide">
						<div class="btn-group">
							<button class="btn btn-primary" type="button" id="saveActionsBtn">Save actions</button>
							<button class="btn btn-warning" type="button" id="saveActionsClusterBtn">Save cluster</button>
						</div>
					</div>
				</div>
				<div class="card bg-light shadow my-3">
					<div class="card-header text-secondary py-2">
						<span class="icon mr-3"><i class="fas fa-list"></i></span>
						<span class="h6 font-weight-bolder my-2">Lists</span>
					</div>
					<div class="card-body p-0">
						<table class="table table-sm table-hover mb-0" id="listMaps">
						</table>
					</div>
				</div>
			</div>

			<div class="tab-pane" id="symbols">
				<div class="card bg-light shadow my-3">
					<div class="card-header text-secondary py-1 d-flex">
						<span class="icon mr-3"><i class="fas fa-tasks"></i></span>
						<span class="h6 font-weight-bolder my-2 ml-0">Symbols and rules</span>
						<div class="align-self-center ml-auto mr-1">
							<button class="btn btn-info btn-sm" id="updateSymbols">
								<i class="fas fa-redo-alt"></i> Update
							</button>
						</div>
					</div>
					<div class="card-body p-0">
						<table class="table table-hover" id="symbolsTable"></table>
					</div>
				</div>
			</div>

			<div class="tab-pane" id="scan">
				<div class="card bg-light shadow my-3">
					<div class="card-header text-secondary py-2">
						<span class="icon mr-3"><i class="fas fa-envelope"></i></span>
						<span class="h6 font-weight-bolder my-2">Scan suspected message</span>
					</div>
					<div class="card-body">
						<div class="row">
							<form class="col-lg-12" id="scanForm">
								<div class="form-group mb-0">
									<label for="scanMsgSource">Message source:</label>
									<textarea class="form-control" id="scanMsgSource" rows="10" placeholder="Paste raw message source"></textarea>
								</div>
							</form>
						</div>
					</div>
					<div class="card-footer">
						<button type="submit" class="btn btn-primary" data-upload="scan"><i class="fas fa-search"></i> Scan message</button>
						<button class="btn btn-secondary float-right" id="scanClean"><i class="fas fa-trash-alt"></i> Clean form</button>
					</div>
				</div>
				<div class="card ro-hide" style="display: none;">
					<div class="card-header text-secondary py-2">
						<span class="icon mr-3"><i class="fas fa-graduation-cap"></i></span>
						<span class="h6 font-weight-bolder my-2">Learn Rspamd</span>
					</div>
					<div class="card-body">
						<div class="row">
							<div class="col-lg-6">
								<div class="card bg-light shadow card-body card p-2">
									<p>Learn Bayessian classifier:</p>
									<form class="form-inline">
										<div class="form-group">
											<div class="btn-group">
												<button class="btn btn-success" type="button" data-upload="ham" disabled><i class="fas fa-thumbs-up"></i> Upload HAM</button>
												<button class="btn btn-danger" type="button" data-upload="spam" disabled><i class="fas fa-thumbs-down"></i> Upload SPAM</button>
											</div>
										</div>
									</form>
								</div>
							</div>
							<div class="col-lg-6">
								<div class="card bg-light shadow card-body card p-2">
									<p>Learn Fuzzy storage:</p>
									<form class="form-inline">
										<div class="form-group">
											<label for="fuzzyFlagText">Flag:</label>
											<input name="fuzzyFlagText" id="fuzzyFlagText" class="form-control ml-1" type="number" value="1"/>
										</div>
										<div class="form-group ml-2">
											<label for="fuzzyWeightText">Weight:</label>
											<input name="fuzzyWeightText" id="fuzzyWeightText" class="form-control ml-1" type="number" value="1"/>
										</div>
										<button class="btn btn-warning ml-2" data-upload="fuzzy" disabled><i class="fas fa-upload"></i> Upload FUZZY</button>
									</form>
								</div>
							</div>
						</div>
					</div>
				</div>

				<div class="card bg-light shadow my-3">
					<div class="card-header text-secondary py-1 d-flex">
						<span class="icon mr-3"><i class="fas fa-eye"></i></span>
						<span class="h6 font-weight-bolder my-2 ml-0">Scan results history</span>
						<div id="scanResult" class="form-inline card-header-form input-group-sm align-self-center ml-auto mr-1">
								<label for="selSymOrder_scan">Symbols order:</label>
								<select id="selSymOrder_scan" class="form-control ml-1">
									<option value="magnitude" selected>Score magnitude</option>
									<option value="score">Score value</option>
									<option value="name">Name</option>
								</select>
							<label for="scan_page_size" class="ml-2">Rows per page:</label>
							<input id="scan_page_size" class="form-control ml-1" value="25" min="1" type="number">
							<button class="btn btn-secondary btn-sm ml-2" id="cleanScanHistory">
								<i class="fas fa-trash-alt"></i> Clean history
							</button>
						</div>
					</div>
					<div class="card-body p-0">
						<div id="scanLog">
							<table class="table mb-0" id="historyTable_scan"></table>
						</div>
					</div>
				</div>
			</div>

			<div class="tab-pane" id="selectors">
				<div class="card bg-light shadow my-3">
					<div class="card-header text-secondary py-2">
						<span class="icon mr-3"><i class="fas fa-envelope"></i></span>
						<span class="h6 font-weight-bolder my-2">Test Rspamd selectors</span>
					</div>
					<div class="card-body py-0">
						<div class="row h-100" id="row-main">
							<div class="col-lg-3 sidebar h-100" id="sidebar-left">
								<div class="p-0 table-responsive mh-100 bg-white">
									<table class="table table-sm small table-striped table-hover table-bordered mb-0" id="selectorsTable-extractors">
										<thead><tr><th>Name</th><th>Description</th></tr></thead>
										<tbody/>
									</table>
								</div>
							</div>

							<div class="col-lg-6 col-12 h-100" id="content">

								<div class="row navbar-light h-100">
									<ul class="nav navbar-nav nav-tabs sidebar-nav border-bottom-0">
										<li class="active text-nowrap nav-item" id="sidebar-tab-left">
											<a class="nav-link border-bottom-0 px-2 py-0" href=""><div id="sidebar-tab-text-left">&#x2195;&ensp;List of extractors</div></a>
										</li>
									</ul>

									<div class="col-lg col-12 mh-100 overflow-auto">
										<div class="row h-100">
											<form class="col-12 d-flex flex-column">
												<div class="row pt-3">
													<div class="col">
														<div class="form-group">
															<label for="selectorsMsgArea">Message source:</label>
															<textarea class="form-control" id="selectorsMsgArea" rows="9" placeholder="Paste raw message source"></textarea>
														</div>
														<button class="btn btn-secondary float-right" id="selectorsMsgClean"><i class="fas fa-trash-alt"></i> Clean form</button>
													</div>
												</div>
												<div class="row pt-3">
													<div class="col">
														<div class="form-group">
															<label for="selectorsSelArea">Selector(s):</label>
															<textarea class="form-control" id="selectorsSelArea" rows="1" placeholder="extractor.transform(arg);extractor.transform(arg);..."></textarea>
														</div>
														<button type="submit" class="btn btn-primary" id="selectorsChkMsgBtn"><i class="fas fa-search"></i> Check message</button>
														<button class="btn btn-secondary float-right" id="selectorsClean"><i class="fas fa-trash-alt"></i> Clean form</button>
													</div>
												</div>
												<div class="row pt-3 flex-grow-1">
													<div class="col d-flex flex-column">
														<div class="form-group h-100 d-flex flex-column">
															<label for="selectorsResArea">Result:</label>
															<textarea class="form-control flex-grow-1" id="selectorsResArea" readonly></textarea>
														</div>
													</div>
												</div>
											</form>
										</div>
									</div>

									<ul class="nav navbar-nav nav-tabs sidebar-nav border-bottom-0">
										<li class="active text-nowrap nav-item" id="sidebar-tab-right">
											<a class="nav-link border-bottom-0 px-2 py-0" href="">&#x2195;&ensp;List of transforms</a>
										</li>
									</ul>
								</div>
							</div>

							<div class="col-lg-3 sidebar h-100" id="sidebar-right">
								<div class="p-0 table-responsive mh-100 bg-white">
									<table class="table table-sm small table-striped table-hover table-bordered mb-0" id="selectorsTable-transforms">
										<thead><tr><th>Name</th><th>Description</th></tr></thead>
										<tbody/>
									</table>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>

			<div class="tab-pane" id="history">

				<div class="card bg-light shadow my-3">
					<div class="card-header text-secondary py-1 d-flex">
						<span class="icon mr-3"><i class="fas fa-eye"></i></span>
						<span class="h6 font-weight-bolder my-2 ml-0">History</span>
						<div class="form-inline card-header-form input-group-sm align-self-center ml-auto mr-1">
							<label for="selSymOrder_history">Symbols order:</label>
							<select id="selSymOrder_history" class="form-control ml-1">
								<option value="magnitude" selected>Score magnitude</option>
								<option value="score">Score value</option>
								<option value="name">Name</option>
							</select>
							<label for="history_page_size" class="ml-2">Rows per page:</label>
							<input id="history_page_size" class="form-control ml-1" value="25" min="1" type="number">
							<button class="btn btn-danger btn-sm ml-2 ro-hide" id="resetHistory">
								<i class="fas fa-times-circle"></i> Reset
							</button>
							<button class="btn btn-info btn-sm ml-2" id="updateHistory">
								<i class="fas fa-redo-alt"></i> Update
							</button>
						</div>
					</div>
					<div class="card-body p-0">
						<div id="historyLog">
							<table class="table" id="historyTable_history"></table>
						</div>
					</div>
				</div>
				<div class="card bg-light shadow my-3 ro-hide" id="errors-history">
					<div class="card-header text-secondary py-1 d-flex">
						<span class="icon mr-3"><i class="fas fa-exclamation-triangle"></i></span>
						<span class="h6 font-weight-bolder my-2 ml-0">Errors</span>
						<div class="align-self-center ml-auto mr-1">
							<button class="btn btn-info btn-sm" id="updateErrors">
								<i class="fas fa-redo-alt"></i> Update
							</button>
						</div>
					</div>
					<div class="card-body p-0">
						<table class="table table-hover mb-0" id="errorsLog"></table>
					</div>
				</div>

			</div>

		</div>
	</div>

</div>

<!-- Common modal -->
<div id="modalDialog" class="modal fade text-center" data-backdrop="static" tabindex="-1" role="dialog">
	<div class="modal-dialog modal-xl d-inline-block mw-100 my-auto text-left">
		<div class="modal-content shadow">
			<div class="modal-header text-secondary py-2">
				<i class="fas my-auto"></i><h6 class="modal-title font-weight-bolder mx-3" id="modalTitle"></h6>
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			</div>
			<div class="modal-body" id="modalBody"></div>
			<div class="modal-footer">
				<div class="btn-group" id="modalSaveGroup">
					<button class="btn btn-primary" id="modalSave">Save changes</button>
					<button class="btn btn-warning" id="modalSaveAll">Save on cluster</button>
				</div>
				<button class="btn btn-secondary" data-dismiss="modal" aria-hidden="true" id="modalClose">Close</button>
			</div>
		</div>
	</div>
</div>

<!-- login modal -->
<div id="connectDialog" class="modal fade" data-backdrop="static" data-keyboard="false" role="dialog">
	<div class="modal-dialog modal-sm modal-dialog-centered">
		<div class="modal-content shadow">
			<div class="modal-header text-secondary py-2">
				<i class="fas fa-key my-auto"></i><h6 class="modal-title font-weight-bolder">Login to Rspamd</h6>
			</div>
			<div class="modal-body" id="connectBody">
				<form id="connectForm">
					<div class="form-group">
						<div class="input-group">
							<input class="form-control"
								   type="password"
								   id="connectPassword"
								   placeholder="Password"
								   data-cip-id="connectPassword">
							<div class="input-group-append">
								<button type="submit" id="connectButton" class="btn btn-primary">Connect</button>
							</div>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>

<script data-main="./js/main.js" src="./js/lib/require.min.js"></script>
</body>
</html>
